
#import "UIColor+HexStringColor.h"
#import "UIView+NoDataShow.h"

//基准宽度值，根据这个宽度值去适配不同屏幕下合理的宽度值
#define TARGET_BASE_SIZE 320.0


@implementation UIView (NoDataShow)
+ (UIImageView *)NoDataImg:(NSString *)image withTip:(NSString *)tip
{
//    UIImageView *bgimv = [[UIImageView alloc] initWithFrame:rect((kScreenWidth - 123)/2, 350, 123, 106)];
    UIImageView *bgimv = [[UIImageView alloc] initWithFrame:rect(0, SafeAreaTopHeight, kScreenWidth, kScreenHeight - SafeAreaTopHeight - SafeAreaBottomHeight)];

    UIImageView *noDataImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"nopicture"]];
    noDataImg.center = CGPointMake(bgimv.frame.size.width/2, kScreenHeight/2);
    noDataImg.contentMode = UIViewContentModeScaleAspectFit;
    UILabel *tipL = [[UILabel alloc] initWithFrame:rect(0, CGRectGetMaxY(noDataImg.frame)+20, 180, 16)];
    tipL.text = tip;
    tipL.textColor = [UIColor colorWithHexString:@"#9B9B9B"];
    tipL.font = FONT(10);
    tipL.center = CGPointMake(bgimv.frame.size.width/2, CGRectGetMaxY(noDataImg.frame)+20);
    tipL.textAlignment = NSTextAlignmentCenter;
    [bgimv addSubview:noDataImg];
    [bgimv addSubview:tipL];
    return bgimv;
}


//依据iPhone5的尺寸得到当前屏幕相对于iPhone5屏幕尺寸的大小
+ (CGFloat)lf_sizeFromIphone5:(CGFloat)size{
    static float width = 0;
    if (width == 0) {
        width = [UIScreen mainScreen].bounds.size.width;
    }
    
    //保持6和6p显示大小相同
    if(width >= 414){
        width = 375;
    }
    
    return width / TARGET_BASE_SIZE * size;
}



@end
